var pool = require('../../config/mysql.connection');
var mapping = require('./mapping/honor.mapping');

module.exports = {
    add : function(param , callback){
        pool.getConnection(function(err , connection){
          
          connection.query($sql.insert , [param.name,param.sex,param.address],function(err,result){
                if(err){
                    throw err;
                }
                if(result){
                    callback(result);
                }
                
                connection.release();
          });
          
        });
    },
    queryAll:function(callback){
        pool.getConnection(function(err,connection){
            if(err) throw err;

            connection.query(mapping.queryAll ,function(err,result){
                if(err) throw err;

                if(result){
                    callback(result);
                }

                connection.release;
            });
        });
    }

};

